<?php
/**
 * Created by PhpStorm.
 * User: 图图
 * Date: 2021-12-16
 * Time: 10:08
 */
namespace app\voice\controller;

use app\common\helper\FormatHelper;
use app\common\service\VoiceService;
use think\Db;

/**
 * 获取语音接口
 * @package app\api\controller
 */
class Voice extends Auth
{
    public $noNeedLogin = [];

    /**
     * 下单商品语音获取接口
     *
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function index()
    {

        $this->result('请求失败', [], 204);
        /*if ($this->request->isPost()) {

            $userInfo = $this->userInfo;
            $voice_url = [];
            $voice_config = Db::name('qt_voice_config')->where('store_id',$userInfo['store_id'])->find();

            //退单播报
            $send_voice_msg = Db::name('qt_send_voice_msg')->where('type',2)->column('content');
            if (!empty($send_voice_msg)){
                foreach ($send_voice_msg as $key => $text) {
                    $result = VoiceService::createVoice($text,$voice_config['play_speed'],$voice_config['play_number']);
                    if ($result['code'] == FormatHelper::SUCCESS) {
                        $voice_url[] = $result['data'];
                    }
                }
                //Db::name('qt_send_voice_msg')->where('type',2)->delete();//查一次清空一次
            }

            //项目播报
            $order_project = Db::name('qt_order_project')
                ->alias('op')
                ->field([
                    'op.id',
                    'op.is_add',
                    'op.name project_name',
                    'op.engineer_id',
                    'r.name as room_name',
                    'op.num',
                    'op.order_type',
                ])
                ->leftJoin('qt_room r','op.room_id=r.id')
                ->where('op.store_id',$userInfo['store_id'])
                ->where('op.is_broadcast',2)//未播报
                ->select();
            $order_type = [1=>'轮排',2=>'点钟',3=>'call钟',4=>'优轮',5=>'加钟'];
            foreach ($order_project as $p_k => $p_v) {

                //if ( $p_k > 1) continue;
                if (empty($p_v['engineer_id'])) {
                    continue;
                }
                $engineer_data = Db::name('qt_users')->where('id',$p_v['engineer_id'])->find();

                //设置工种不语音播报
                if (!empty($voice_config['noplay_work_type'])) {
                    $type_id_arr = explode(',',$voice_config['noplay_work_type']);
                    if (in_array($engineer_data['type_id'],$type_id_arr)) {
                        continue;
                    }
                }

                $is_add_str = $p_v['is_add'] == 1 ? '加班': '';
                $text =  $engineer_data['work_number'] .' 号   '.$p_v['room_name']. ' 房  '.$p_v['project_name'] . '   '.$is_add_str.$order_type[$p_v['order_type']];
                $result = VoiceService::createVoice($text,$voice_config['play_speed'],$voice_config['play_number']);
                if ($result['code'] == FormatHelper::SUCCESS) {
                    $voice_url[] = $result['data'];
                }
                Db::name('qt_order_project')->where('id',$p_v['id'])->update(['is_broadcast'=>1]);
            }

            $this->result('查询成功', $voice_url, 200);
        }*/

        $this->result('请求失败', [], 204);
    }








}
